package com.xinheyun.demo.leetcode;

/**
 * @description: TODO
 * @author: Sarah
 * @modified By: Sarah
 * @date: Created in 2021/9/7 18:18
 * @version:v1.0
 */
public class test1221 {

    public int balancedStringSplit(String s) {
        int rWord=0;
        int lWord=0;
        char[] char1 = s.toCharArray();
        int ans = 0 ;
        for (char c:char1){
            if(c == 'R'){
                rWord++;
            }
            if(c == 'L'){
                lWord++;
            }
            if(rWord==lWord){
                ans++;
            }
        }
        return ans;
    }

}
